<?php
namespace app\index\controller;

use app\index\model\CompanyModel;
use think\admin\Controller;

/**
 * Class Index
 * 公司联系方式操作
 * 
 * @package app\index\controller
 */
class Company extends Controller
{

    public function index(){
        $company = CompanyModel::where(['status' => 1])->order('id asc')->find();


        // 获取今日更新过的数据量
        $start_time = strtotime(date('Y-m-d'));
        $end_time = $start_time + 60 * 60 * 24;
        $today_handle = CompanyModel::whereIn('status', [2, 3])->whereBetween('update_time', [$start_time, $end_time])->count();
        $remain_count = CompanyModel::where(['status' => 1])->count();
        $this->company = $company;
        $this->today_handle = $today_handle;
        $this->remain_count = $remain_count;
        // dump($company);
        return $this->fetch();
    }

     public function operate(){

        $id = input('id', 0, 'intval');
        $status = input('status', 0, 'intval');
        $result = CompanyModel::where(['id' => $id])->update(['status' => $status, 'update_time' => time()]);
        return 'success';
     }

}